<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="comm.util.RequestManager"%>
<%@page import="comm.util.SoptHashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="styledaco.board.BoardProc"%>
<%@page import="styledaco.board.CategoryProc"%>
<%@page import="comm.util.CommUtil"%>
<%@page import="statics.SoptVars"%>      
<%
SoptHashMap hm = RequestManager.getRequest(request);
ArrayList boardList = null;

CategoryProc category = new CategoryProc();
String curCategory = CommUtil.NVL(hm.get("S"), CommUtil.NVL(hm.get("CATEGORY_SEQ"),category.getCategorySeqOfFirstInCurrentType(SoptVars.MENU_STYLE)));

int pageSize = SoptVars.PAGE_SIZE;
int pageCount = 1;
int totalCount = 0;
int curPage = Integer.parseInt(CommUtil.NVL(hm.get("P"),"1"));
if(curPage<1)curPage = 1;

BoardProc board = new BoardProc();
boardList = board.getBoardList(curCategory,curPage,-1);

String curArticle = CommUtil.NVL(hm.get("A"),"");
%>
<script type="text/javascript">
	changeMenu('Style');
	<%if(curArticle.length()>0){ %>
		readBoard('<%=curArticle%>');
	<%}%>
</script>
<div class="bodyContentLayerBg">
	<div class="bodyContentLayerInnerBg boardOutline">
		<%if(boardList!=null && boardList.size()>0){
			totalCount = Integer.parseInt(((SoptHashMap)boardList.get(0)).get("TOTAL_COUNT").toString());
			pageCount = totalCount/pageSize;
			if(totalCount % pageSize > 0)pageCount++;
			%>
			<ol class="boardListOl">
			<%for(int i = 0; i< boardList.size();i++){
				SoptHashMap curBoard = (SoptHashMap)boardList.get(i);%>
				<li>
					<div class="boardSeq floatLeft"><%=curBoard.get("BOARD_SEQ") %></div>
					<div class="boardTitle floatLeft" style="text-indent:<%=curBoard.get("PARENT_SEQ").toString().equals(curBoard.get("BOARD_SEQ").toString())?0:15%>px;">
						<a href="javascript:void(0);" onclick="javascript:readBoard('<%=curBoard.get("BOARD_SEQ")%>')" >
							<%=curBoard.get("BOARD_TITLE") %> <%=CommUtil.NVL(curBoard.get("REPLY_COUNT"),"0").equals("0")?"":"<span class='replyCount'>("+curBoard.get("REPLY_COUNT")+")<span>"%>
						</a>
					</div>
					<span class="boardWriter boardRegdate floatRight">
						<%=curBoard.get("MEMBER_NICK") %>,
						<%=curBoard.get("BOARD_REGDATE") %>
					</span>
					<div class="clear"></div>
				</li>
			<%} %>
			</ol>
		<%}else{ %>
			<div>등록된카테고리(게시판)가 없습니다.</div>
		<%} %>
		
		<div class="pagingLayer">
			<form method="post" onsubmit="return getBoardListByJustCategoryPage('<%=curCategory%>','Style','');">
				<input type="hidden" id="maxPage" value="<%=pageCount%>">
			<ul>
				<%if(curPage>1){ %>
				<li><input type="button" value="이전페이지" onclick="getBoardListByJustCategoryPage('<%=curCategory%>','Style',<%=curPage>1?curPage-1:1%>)"></li>
				<%} %>
				<%if(curPage<pageCount){ %>
				<li><input type="button" value="다음페이지" onclick="getBoardListByJustCategoryPage('<%=curCategory%>','Style',<%=curPage+1%>)"></li>
				<%} %>
				
				<li><input type="text" name="p" id="setPage" value="<%=curPage%>">/<%=pageCount%></li>
			</ul>
			</form>
		</div>
		
		<%if(session.getAttribute("SESSION_MEMBER_SEQ")!=null ) {%>
		<div class="writeButtonLayer">
			<input type="hidden" id="curCategorySeq" value="<%=curCategory%>">
			<input type="button" value="글쓰기" onclick="javascript:writeBoard('Community');">
		</div>
		<%} %>
	</div>
</div>